<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Java技术栈目录树</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }
        
        body {
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            color: #333;
            line-height: 1.6;
            padding: 20px;
            min-height: 100vh;
        }
        
        .container {
            max-width: 1200px;
            margin: 0 auto;
        }
        
        header {
            text-align: center;
            margin-bottom: 30px;
            padding: 20px;
            background: #fff;
            border-radius: 10px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
        }
        
        h1 {
            color: #e74c3c;
            margin-bottom: 10px;
        }
        
        .description {
            color: #7f8c8d;
            max-width: 800px;
            margin: 0 auto;
        }
        
        .search-box {
            display: flex;
            justify-content: center;
            margin: 20px 0;
        }
        
        .search-box input {
            width: 100%;
            max-width: 500px;
            padding: 12px 20px;
            border: 2px solid #ddd;
            border-radius: 50px;
            font-size: 16px;
            outline: none;
            transition: border-color 0.3s;
        }
        
        .search-box input:focus {
            border-color: #3498db;
        }
        
        .tree-container {
            background: #fff;
            border-radius: 10px;
            padding: 30px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
            overflow-x: auto;
        }
        
        .java-tree {
            list-style: none;
            padding-left: 0;
        }
        
        .java-tree li {
            position: relative;
            padding: 8px 10px 8px 30px;
            margin: 5px 0;
            cursor: pointer;
            transition: all 0.3s;
        }
        
        .java-tree li:hover {
            background-color: #f8f9fa;
            border-radius: 5px;
        }
        
        .java-tree li.has-children::before {
            content: '\f107';
            font-family: 'Font Awesome 6 Free';
            font-weight: 900;
            position: absolute;
            left: 10px;
            top: 50%;
            transform: translateY(-50%);
            transition: transform 0.3s;
        }
        
        .java-tree li.has-children.collapsed::before {
            transform: translateY(-50%) rotate(-90deg);
        }
        
        .java-tree ul {
            list-style: none;
            padding-left: 30px;
            display: none;
        }
        
        .java-tree li.active > ul {
            display: block;
        }
        
        .category {
            font-weight: bold;
            color: #2c3e50;
        }
        
        .framework {
            color: #2980b9;
        }
        
        .tool {
            color: #27ae60;
        }
        
        .database {
            color: #8e44ad;
        }
        
        .build-tool {
            color: #d35400;
        }
        
        .icon {
            margin-right: 8px;
            width: 20px;
            text-align: center;
        }
        
        .controls {
            display: flex;
            justify-content: center;
            gap: 15px;
            margin: 20px 0;
        }
        
        button {
            padding: 10px 20px;
            background: #3498db;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            transition: background 0.3s;
        }
        
        button:hover {
            background: #2980b9;
        }
        
        footer {
            text-align: center;
            margin-top: 30px;
            color: #7f8c8d;
            font-size: 14px;
        }
        
        @media (max-width: 768px) {
            .tree-container {
                padding: 15px;
            }
            
            .java-tree li {
                padding: 6px 8px 6px 25px;
                font-size: 14px;
            }
            
            .java-tree ul {
                padding-left: 20px;
            }
            
            .controls {
                flex-direction: column;
                align-items: center;
            }
            
            button {
                width: 100%;
                max-width: 300px;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <header>
            <h1>Java技术栈目录树</h1>
            <p class="description">可视化展示Java生态系统中的主要技术、框架和工具。点击分类展开或折叠，使用搜索框快速查找特定技术。</p>
        </header>
        
        <div class="search-box">
            <input type="text" id="searchInput" placeholder="搜索Java技术或工具...">
        </div>
        
        <div class="controls">
            <button id="expandAll">展开所有</button>
            <button id="collapseAll">折叠所有</button>
            <button id="resetView">重置视图</button>
        </div>
        
        <div class="tree-container">
            <ul class="java-tree" id="javaTree">
                <!-- Java基础 -->
                <li class="category has-children">
                    <span class="icon"><i class="fas fa-code"></i></span>Java基础
                    <ul>
                        <li>Java语法基础</li>
                        <li>面向对象编程</li>
                        <li>集合框架</li>
                        <li>I/O与NIO</li>
                        <li>多线程与并发</li>
                        <li>反射机制</li>
                        <li>注解</li>
                        <li>Lambda表达式</li>
                    </ul>
                </li>
                
                <!-- Java虚拟机 -->
                <li class="category has-children">
                    <span class="icon"><i class="fas fa-cogs"></i></span>Java虚拟机(JVM)
                    <ul>
                        <li>内存模型</li>
                        <li>垃圾回收机制</li>
                        <li>性能调优</li>
                        <li>类加载机制</li>
                        <li>JVM参数配置</li>
                    </ul>
                </li>
                
                <!-- 开发框架 -->
                <li class="category has-children">
                    <span class="icon"><i class="fas fa-layer-group"></i></span>开发框架
                    <ul>
                        <li class="framework">Spring框架
                            <ul>
                                <li>Spring Core</li>
                                <li>Spring MVC</li>
                                <li>Spring Boot</li>
                                <li>Spring Cloud</li>
                                <li>Spring Security</li>
                                <li>Spring Data</li>
                            </ul>
                        </li>
                        <li class="framework">Jakarta EE</li>
                        <li class="framework">Micronaut</li>
                        <li class="framework">Quarkus</li>
                        <li class="framework">Play Framework</li>
                    </ul>
                </li>
                
                <!-- 数据库技术 -->
                <li class="category has-children">
                    <span class="icon"><i class="fas fa-database"></i></span>数据库技术
                    <ul>
                        <li class="database">关系型数据库
                            <ul>
                                <li>MySQL</li>
                                <li>PostgreSQL</li>
                                <li>Oracle</li>
                            </ul>
                        </li>
                        <li class="database">NoSQL数据库
                            <ul>
                                <li>MongoDB</li>
                                <li>Redis</li>
                                <li>Elasticsearch</li>
                                <li>Cassandra</li>
                            </ul>
                        </li>
                        <li class="database">ORM框架
                            <ul>
                                <li>Hibernate</li>
                                <li>MyBatis</li>
                                <li>JPA</li>
                            </ul>
                        </li>
                    </ul>
                </li>
                
                <!-- 构建工具 -->
                <li class="category has-children">
                    <span class="icon"><i class="fas fa-wrench"></i></span>构建工具
                    <ul>
                        <li class="build-tool">Maven</li>
                        <li class="build-tool">Gradle</li>
                        <li class="build-tool">Ant</li>
                    </ul>
                </li>
                
                <!-- 测试框架 -->
                <li class="category has-children">
                    <span class="icon"><i class="fas fa-vial"></i></span>测试框架
                    <ul>
                        <li>JUnit</li>
                        <li>TestNG</li>
                        <li>Mockito</li>
                        <li>PowerMock</li>
                        <li>Selenium</li>
                    </ul>
                </li>
                
                <!-- 微服务与云原生 -->
                <li class="category has-children">
                    <span class="icon"><i class="fas fa-cloud"></i></span>微服务与云原生
                    <ul>
                        <li>Spring Cloud</li>
                        <li>Dubbo</li>
                        <li>Kubernetes</li>
                        <li>Docker</li>
                        <li>Service Mesh</li>
                    </ul>
                </li>
                
                <!-- 中间件技术 -->
                <li class="category has-children">
                    <span class="icon"><i class="fas fa-server"></i></span>中间件技术
                    <ul>
                        <li>消息队列
                            <ul>
                                <li>Kafka</li>
                                <li>RabbitMQ</li>
                                <li>RocketMQ</li>
                            </ul>
                        </li>
                        <li>RPC框架
                            <ul>
                                <li>Dubbo</li>
                                <li>gRPC</li>
                            </ul>
                        </li>
                        <li>配置中心
                            <ul>
                                <li>Apollo</li>
                                <li>Nacos</li>
                            </ul>
                        </li>
                    </ul>
                </li>
            </ul>
        </div>
        
        <footer>
            <p>© 2023 Java技术栈目录树 | 使用HTML、CSS和JavaScript实现</p>
        </footer>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            const treeItems = document.querySelectorAll('.java-tree .has-children');
            const searchInput = document.getElementById('searchInput');
            const expandAllBtn = document.getElementById('expandAll');
            const collapseAllBtn = document.getElementById('collapseAll');
            const resetViewBtn = document.getElementById('resetView');
            
            // 初始化树形结构
            treeItems.forEach(item => {
                item.classList.add('collapsed');
                
                item.addEventListener('click', function(e) {
                    // 防止点击子元素时触发父元素的事件
                    if (e.target !== e.currentTarget) return;
                    
                    this.classList.toggle('collapsed');
                    this.classList.toggle('active');
                });
            });
            
            // 搜索功能
            searchInput.addEventListener('input', function() {
                const searchTerm = this.value.toLowerCase();
                const allItems = document.querySelectorAll('.java-tree li');
                
                if (searchTerm === '') {
                    // 重置视图
                    allItems.forEach(item => {
                        item.style.display = 'block';
                        item.style.backgroundColor = '';
                    });
                    return;
                }
                
                allItems.forEach(item => {
                    const text = item.textContent.toLowerCase();
                    
                    if (text.includes(searchTerm)) {
                        item.style.display = 'block';
                        item.style.backgroundColor = '#fff9c4';
                        
                        // 展开所有父元素
                        let parent = item.parentElement;
                        while (parent && parent.classList.contains('java-tree')) {
                            if (parent.previousElementSibling && parent.previousElementSibling.classList.contains('has-children')) {
                                parent.previousElementSibling.classList.remove('collapsed');
                                parent.previousElementSibling.classList.add('active');
                            }
                            parent = parent.parentElement;
                        }
                    } else {
                        item.style.display = 'none';
                        item.style.backgroundColor = '';
                    }
                });
            });
            
            // 展开所有
            expandAllBtn.addEventListener('click', function() {
                treeItems.forEach(item => {
                    item.classList.remove('collapsed');
                    item.classList.add('active');
                });
            });
            
            // 折叠所有
            collapseAllBtn.addEventListener('click', function() {
                treeItems.forEach(item => {
                    item.classList.add('collapsed');
                    item.classList.remove('active');
                });
            });
            
            // 重置视图
            resetViewBtn.addEventListener('click', function() {
                searchInput.value = '';
                const allItems = document.querySelectorAll('.java-tree li');
                
                allItems.forEach(item => {
                    item.style.display = 'block';
                    item.style.backgroundColor = '';
                });
                
                // 折叠所有节点
                treeItems.forEach(item => {
                    item.classList.add('collapsed');
                    item.classList.remove('active');
                });
            });
        });
    </script>
</body>
</html>